#include "common.h"

#include <sys/ipc.h>
#include <sys/shm.h>
#include <string.h>

int main()
{
	key_t key = ftok("./", 18);
	if(key < 0)
		err_sys("ftok error\n");

	int shmid = shmget(key, 1024, IPC_CREAT);

	char *shmdata = shmat(shmid, NULL, 0);

	if(shmid < 0)
		err_sys("shmget error\n");

	if(shmdata == NULL)
		err_sys("shmat error\n");
	while(1)
	{
		while(strlen(shmdata) != 0)
		{
			sleep(1);
			printf("data : %s\n", shmdata);
			memset(shmdata, 0, 1024);
		}
	}

	shmctl(shmid, IPC_RMID, NULL);

	return 0;

}
